package com.shijie.newvideo;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.shijie.newvideo.base.BaseRecyclerViewAdapter;
import com.shijie.newvideo.base.BaseRecyclerViewHolder;
import com.shijie.newvideo.databinding.ItemMyOrderBinding;

import java.util.List;

/**
 * 我的订单
 */
public class VodListAdapter extends BaseRecyclerViewAdapter<VodBean.ListDTO> {

    public VodListAdapter(Context context, List<VodBean.ListDTO> data) {
        super(context, data);
    }

    @Override
    protected BaseRecyclerViewHolder<VodBean.ListDTO> createViewHolder(View itemView) {
        return new ViewHolder(ItemMyOrderBinding.bind(itemView));
    }

    @Override
    protected int getItemLayoutRes(int viewType) {
        return R.layout.item_my_order;
    }

    class ViewHolder extends BaseRecyclerViewHolder<VodBean.ListDTO> {

        private final ItemMyOrderBinding binding;

        public ViewHolder(ItemMyOrderBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }

        @Override
        public void bindTo(final VodBean.ListDTO bean, final int position) {
            super.bindTo(bean, position);
            binding.tvName.setText(bean.getType_name());  // 示例：显示订单ID
            ImageLoad.loadCicleRadiusImage(mContext, binding.ivImage, bean.getVod_pic(), R.drawable.zhuanti_shadow_bg, ImageLoad.imgCorner_large, ImageView.ScaleType.CENTER_CROP);//有圆角
            setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(View itemView, int position) {
                    PlayDetailActivity.intentTo(mContext, bean.getVod_id());
                }
            });
        }
    }
}
